Subject: Re: Calling libraries from boopsi objects
From: [email-masked] (Christoph Feck IRZ)
Date: Tue, 17 May 1994 17:47:29 GMT
Newsgroups: comp.sys.amiga.programmer

In article <[email-masked]>, [email-masked] (Carl Laurence Gonsalves) writes:
> I'm working on a simple boopsi gadget, and I'm stuck on one thing:
> 
> Where do I store library bases, and when should I get them?

Put a pointer to your global (per-class) data in cl->cl_UserData.
Open all the libraries before you are going to make your class
handle available.

> The reason I'm asking is this: the dispatcher is called from Intuition's
> context, while the function that creates the class is called from the
> application's context. Theoretically, and library bases I get from the
> app's context might be invalid in Intuition's context, right? (this is the
> "sharing library bases" issue)

I'd say that exec, graphics, intuition, utility and layers
are safe to share (Commodore does it, too).  If your gadget
needs other libraries, well, open them in the dispatcher,
BUT also open them in your class initialization just to make
sure they are in memory (and stay there until the class is
freed).  If OpenLibrary() would need to load, you could
end up creating a deadlock, when ramlib puts a 'Please
insert LIBS:' requester (which you can't disable because
tasks like input.device don't have pr_WindowPtr...)

> Since I'll probably always be using the libraries within the dispatcher's
> context (ie: Intuition's) I guess I should open the lib's in the
> dispatcher, say in the OM_NEW method.

No!  The OM_NEW method will be called on the applications
process, but the GM_HITTEST will be called from input.device.
You will have to open them whenever you need them, not just
once in the object creation (which means the library pointers
are local variables in your dispatcher function, and not
stored in either per-class or per-object data).

If you have further questions, feel free to ask.

Mr. BOOPSI :)

3k// Christoph Feck, TowerSystems - BOOPSI Class Development
\X/ Amiga - Intuition inside.